<form id="form1" method="post">
<fieldset id="fd1" style="width:950px;">
	<legend><span>客服信息输入</span></legend>
	<div class="fieldset-body">
		<table class="form-table" border="0" cellpadding="1" cellspacing="2">
			<tr>
				<td class="form-label" style="width:80px;">类型:</td>
				<td style="width:150px"><input name="types" id="types" class="mini-combobox" textField="name" valueField="id" value="1" data="JS.CONST[8]" allowInput="true" style="width:100%;"/></td>
				<td class="form-label" style="width:80px;">状态:</td>
				<td style="width:180px"><input name="status" id="status" class="mini-combobox" textField="name" valueField="name" data="[{name:'未处理'},{name:'处理中'},{name:'已处理'},{name:'已作废'}]" allowInput="true" style="width:100%;"/></td>
				<td class="form-label" style="width:80px;">标题:</td>
				<td style="width:180px"><input id="title" class="mini-textbox" emptyText="请输入标题" style="width:100%;"/></td>
				<td style="width:80px;">&nbsp;</td>
			</tr>
			<tr>
				<td class="form-label" style="width:80px;">被投诉机构:</td>
				<td style="width:150px"><input name="agency_id" id="agency_id" expandOnLoad="true" class="mini-treeselect" url="/common/agency" multiSelect="false" textField="name" valueField="id" parentField="parent" checkRecursive="true" showFolderCheckBox="true" style="width:100%;"/></td>
				<td class="form-label" style="width:80px;">投诉时间:</td>
				<td style="width:180px"><input name="updated1" id="updated1" class="mini-datepicker" format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true" value="" style="width:100%;"/></td>
				<td class="form-label" style="width:80px;">～</td>
				<td style="width:180px"><input name="updated2" id="updated2" class="mini-datepicker" format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true" value="" style="width:100%;"/></td>
				<td class="form-label" style="width:80px;"><a class="mini-button" iconCls="icon-search" id="search">查询</a></td>
			</tr>
		</table>
	</div>
</fieldset>
</form>
<div class="mini-toolbar" style="padding:0px;margin:3px 0px 0px 0px;border-bottom:0;">
	<table style="width:100%;">
		<tr>
			<td style="width:100%;">
				<a class="mini-button" iconCls="icon-undo" id="btnRun" onClick="btnRun()" plain="true">处理中</a>
				<span class="separator"></span>
				<a class="mini-button" iconCls="icon-node" id="btnCon" onClick="btnCon()" plain="true">处理结果</a>
				<span class="separator"></span>
				<a class="mini-button" iconCls="icon-close" id="btnDel" onClick="btnDel()" plain="true">无效作废</a>
				<span class="separator"></span>
				<a class="mini-button" iconCls="icon-search" onClick="CustomerInfo('customs_id')" plain="true">查看顾客详情</a>
			</td>
		</tr>
	</table>
</div>
<div id="grid1" class="mini-datagrid" frozenStartColumn="0" frozenEndColumn="4" style="width:100%;height:70%;" idField="id" allowResize="false" borderStyle="border-left:0;border-right:0;" url="/service/complsintsTwo" >
	<div property="columns">
		<div type="indexcolumn"></div>
		<div field="types" headerAlign="center" align="center" width="60">类型</div>
		<div field="status" headerAlign="center" align="center" width="60">状态</div>
		<div field="customer" width="80">客户</div>
		<div field="contact" width="100">联系方式</div>
		<div field="title" width="100">标题</div>
		<div field="content" width="300">内容</div>
		<div field="inputStaff" width="60">客服</div>
		<div header="相关责任" headerAlign="center">
			<div property="columns">
				<div field="agency" width="120">责任机构</div>
				<div field="blamename" width="150">责任人</div>
			</div>
		</div>
		<div header="信息处理" headerAlign="center">
			<div property="columns">
				<div field="pagency" width="120">处理机构</div>
				<div field="pstaff" width="80">处理人</div>
				<div field="process_result" width="300">处理结果</div>
				<div field="process_time" dateFormat="yyyy-MM-dd HH:mm:ss" width="120">处理时间</div>
			</div>
		</div>
		<div field="updated" headerAlign="center" align="center" dateFormat="yyyy-MM-dd" width="100">创建时间</div>
	</div>
</div>
<script type="text/javascript">
mini.parse();
mini.get("btnRun").disable();
mini.get("btnCon").disable();
mini.get("btnDel").disable();
var urlUpd="/service/inputUpd";
var form = new mini.Form("form1");
var grid = mini.get("grid1");
grid.load({
	types:mini.get("types").getText(),
	status:mini.get("status").getValue(),
	title:mini.get("title").getValue(),
	agency_id:mini.get("agency_id").getValue(),
	updated1:mini.get("updated1").getValue(),
	updated2:mini.get("updated2").getValue()
});

//查询功能
$("#search").click(function(){
	grid.load({
		types:mini.get("types").getText(),
		status:mini.get("status").getValue(),
		title:mini.get("title").getValue(),
		agency_id:mini.get("agency_id").getValue(),
		updated1:mini.get("updated1").getValue(),
		updated2:mini.get("updated2").getValue()
	});
});

//行选择设定功能状态
grid.on("selectionchanged",function(e){
	var row = grid.getSelected();
	if (row != null) {
		if(row.status=="未处理"){
			mini.get("btnRun").enable();
			mini.get("btnCon").disable();
			mini.get("btnDel").enable();
		}

		if(row.status=="处理中"){
			mini.get("btnRun").disable();
			mini.get("btnCon").enable();
			mini.get("btnDel").disable();
		}

		if(row.status=="已处理"){
			mini.get("btnRun").disable();
			mini.get("btnCon").disable();
			mini.get("btnDel").disable();
		}

		if(row.status=="已作废"){
			mini.get("btnRun").disable();
			mini.get("btnCon").disable();
			mini.get("btnDel").disable();
		}
	}
});

//设置行样式
grid.on("drawcell", function (e) {
	if(e.field=="status"){
		if(e.value=="未处理"){
			e.cellStyle = "color:limegreen;";
		}
		if(e.value=="处理中"){
			e.cellStyle = "color:darkcyan;";
		}
		if(e.value=="已处理"){
			e.cellStyle = "color:orange;";
		}
		if(e.value=="已作废"){
			e.cellStyle = "color:red;";
		}
	}
});

//投诉处理中
function btnRun(){
	var row = grid.getSelected();
	if (row != null) {
		$.post('/customer/complaintsRun',{id:row.id},function(data){
			if(data.code=='OK'){
				grid.load({
					types:mini.get("types").getText(),
					status:mini.get("status").getValue(),
					title:mini.get("title").getValue(),
					agency_id:mini.get("agency_id").getValue(),
					updated1:mini.get("updated1").getValue(),
					updated2:mini.get("updated2").getValue()
				});
				parent.$.dooDialog.alert('咨询投诉处理中......');
			}else{
				parent.$.dooDialog.alert('修改状态失败！');
				return false;
			}
		},'json');
	} else {
		parent.$.dooDialog.alert("请选中一条记录");
	}
}

//投诉作废
function btnDel(){
	var row = grid.getSelected();
	if (row != null) {
		parent.$.dooDialog.confirm("你确定要把这个咨询投诉作废吗？",function(){
			$.post('/customer/complaintsDel',{id:row.id},function(data){
				if(data.code=='OK'){
					grid.load({
						types:mini.get("types").getText(),
						status:mini.get("status").getValue(),
						title:mini.get("title").getValue(),
						agency_id:mini.get("agency_id").getValue(),
						updated1:mini.get("updated1").getValue(),
						updated2:mini.get("updated2").getValue()
					});
					parent.$.dooDialog.alert('咨询投诉作废成功！');
				}else{
					parent.$.dooDialog.alert('咨询投诉作废失败！');
					return false;
				}
			},'json');
		});
	} else {
		parent.$.dooDialog.alert("请选中一条记录");
	}
}

//派工到下属组织机构
function btnCon(){
	var row = grid.getSelected();
	if (row != null) {
		mini.open({
			url: "/customer/complaintsCon",
			title: "编辑处理结果", width: 530,height:280,
			onload: function(){
				var iframe = this.getIFrameEl();
				var data = { action: "edit",id:row.id};
				iframe.contentWindow.SetData(data);
			},
			ondestroy:function(action){
				grid.load({
					types:mini.get("types").getText(),
					status:mini.get("status").getValue(),
					title:mini.get("title").getValue(),
					agency_id:mini.get("agency_id").getValue(),
					updated1:mini.get("updated1").getValue(),
					updated2:mini.get("updated2").getValue()
				});
			}
		});
		$(".mini-panel-border .mini-panel-body iframe").css("height","95%");
	} else {
		parent.$.dooDialog.alert("请选中一条记录");
	}
}
</script>
